import axios from 'axios'
import configKey from '../config';
export function request(config) {
    const instance = axios.create({
        baseURL: 'https://devapi.qweather.com/v7',
        timeout: 5000
    })
    instance.interceptors.request.use(res => {
        res.params.key = configKey.heF_key;
        return res
    }, err => {
        return Promise.reject(err);
    })
    // 发送网络请求
    return instance(config);
}

// 城市
export function cityRequest(config) {
    const instance = axios.create({
        baseURL: 'https://geoapi.qweather.com/v2',
        timeout: 5000
    })

    instance.interceptors.request.use(res => {
        res.params.key = configKey.heF_key;
        res.params.range = 'cn';
        return res
    }, err => {
        return Promise.reject(err);
    })
    // 发送网络请求
    return instance(config);
}